using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PocketApps
{
    public partial class WikiForm : Form
    {
        enum WikiState { Edit, View, Save };

        WikiState CurrentState = WikiState.View;
        string currentPageName = "";

        public WikiForm()
        {
            InitializeComponent();
        }

        private void miClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void miViewEdit_Click(object sender, EventArgs e)
        {
            switch (CurrentState)
            {
                case WikiState.Edit:
                    if (currentPageName == "")
                    {
                        currentPageName = ResolvePageName(tbWikiEdit.Text);
                        bool pageSaved = SavePage(currentPageName);
                    }
                    else
                    {
                        if (PageVersionDiff(currentPageName))
                        {

                        }
                    }


                    CurrentState = WikiState.View;

                    break;
                case WikiState.View:
                    break;
                case WikiState.Save:
                    break;
                default:
                    break;
            }
        }

        /// <summary>
        /// check for differences in stored page and current page
        /// </summary>
        /// <param name="currentPageName"></param>
        /// <returns></returns>
        private bool PageVersionDiff(string currentPageName)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private bool SavePage(string currentPageName)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private string ResolvePageName(string p)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private void WikiForm_Load(object sender, EventArgs e)
        {
            tbWikiEdit.Text = LoadPage("start.wiki");
            wbWikiView.DocumentText = ParsePage("start.wiki");

        }

        private string ParsePage(string p)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private string LoadPage(string p)
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}